<?php
session_start();
include("../include/config.inc.php");
include("../include/version.inc.php");
include("../include/tables.inc.php");
include("../include/funktion.inc.php");
include("../include/rights.inc.php");


if(!isset($_SESSION['userid']))
   weiterleitung("index.php");

$rights = $_SESSION['ses_rights'];
$menu = menu($rights);

if(!check($_SERVER['PHP_SELF'],$rights))
  weiterleitung("uebersicht.php");

$fehler = "";
if(!is_numeric($id = $_GET['id'])) $id = 0;

$abfrage = "SELECT `name`,`size`,`mime`,`value` FROM `$anhangdb` WHERE `id` = '$id';";
$ergebnis = mysql_query($abfrage) OR die("Datei kann nicht geladen werden");
$row = mysql_fetch_object($ergebnis);


ob_start();
header("Cache-control: private");
header("Content-type: $row->mime");
header("Content-Disposition: filename=\"$row->name\"");
header("Content-Length: $row->size");
header("Pragma: no-cache");
header("Expires: 0");

echo base64_decode(str_replace("\r\n","",$row->value));
ob_end_flush();
?>
